package com.ruoyi.web.controller.ring.app;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ring.domain.dto.GeneralSecondDTO;
import com.ruoyi.ring.service.IBloodOxygenSecondService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 血氧二级页 （APP）
 */
@Slf4j
@RestController
@RequestMapping("/ring/app/ring_blood_second")
public class BloodOxygenSecondController extends BaseController
{
    @Resource
    private IBloodOxygenSecondService secondService;
    /**
     * 查询日历数据列表-app
     */
    @GetMapping("/query-calendar-list")
    public AjaxResult queryCalendarList(GeneralSecondDTO secondDTO){
        long userId = SecurityUtils.getUserId();
        log.info("查询日历数据列表: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.queryCalendarList(secondDTO));
    }
    /**
     * 二级页 血氧平均值
     */
    @GetMapping("/query-blood-oxygen-average")
    public AjaxResult queryBloodOxygenAverage(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("血氧平均值: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.queryBloodOxygenAverage(secondDTO));
    }
    /**
     * 二级页 夜间血氧监测
     */
    @GetMapping("/query-blood-oxygen-monitor")
    public AjaxResult queryBloodOxygenMonitor(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("夜间血氧监测: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.queryBloodOxygenMonitor(secondDTO));
    }

    /**
     * 三级页 统计-手动测量记录
     */
    @GetMapping("/query-blood-oxygen-info")
    public AjaxResult queryBloodOxygenInfo(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("手动测量记录: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.queryBloodOxygenInfoList(secondDTO));
    }

    /**
     * 四级页 手动血氧详情
     */
    @GetMapping("/query-blood-oxygen-detail/{id}")
    public AjaxResult queryBloodOxygenDetail(@PathVariable("id") Long id)
    {
        return AjaxResult.success(secondService.queryBloodOxygenDetail(id));
    }

    /**
     * 四级页 当天往前取7条数据
     */
    @GetMapping("/query-blood-oxygen-seven-info")
    public AjaxResult queryBloodOxygenSevenInfo(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("当天往前取7条数据: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.queryBloodOxygenSevenInfo(secondDTO));
    }


}
